import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";

@Index("account", ["account"], { unique: true })
@Entity("merchant", { schema: "cabinet" })
export class Merchant {
  @PrimaryGeneratedColumn({ type: "int", name: "merchant_id", unsigned: true })
  merchantId: number;

  @Column("varchar", { name: "merchant_name", comment: "名称", length: 15 })
  merchantName: string;

  @Column("varchar", {
    name: "account",
    unique: true,
    comment: "账号",
    length: 20,
  })
  account: string;

  @Column("char", { name: "password", comment: "密码", length: 32 })
  password: string;

  @Column("varchar", { name: "salt", length: 12 })
  salt: string;

  @Column("decimal", {
    name: "profit_rate",
    comment: "分润比例",
    precision: 5,
    scale: 2,
    default: () => "'0.00'",
  })
  profitRate: string;

  @Column("decimal", {
    name: "withdrawal_rate",
    comment: "提现费率",
    precision: 5,
    scale: 2,
    default: () => "'0.00'",
  })
  withdrawalRate: string;

  @Column("decimal", {
    name: "amount",
    comment: "余额",
    precision: 10,
    scale: 2,
    default: () => "'0.00'",
  })
  amount: string;

  @Column("decimal", {
    name: "withdrawal_amount",
    comment: "已提现",
    precision: 10,
    scale: 2,
    default: () => "'0.00'",
  })
  withdrawalAmount: string;

  @Column("decimal", {
    name: "frozen_amount",
    comment: "冻结",
    precision: 10,
    scale: 2,
    default: () => "'0.00'",
  })
  frozenAmount: string;

  @Column("decimal", {
    name: "total_charge_amount",
    comment: "总收入",
    precision: 12,
    scale: 2,
    default: () => "'0.00'",
  })
  totalChargeAmount: string;

  @Column("float", {
    name: "total_charge_energy",
    precision: 15,
    scale: 5,
    default: () => "'0.00000'",
  })
  totalChargeEnergy: number;

  @Column("int", {
    name: "total_charge_time",
    comment: "总充电时长，秒",
    unsigned: true,
    default: () => "'0'",
  })
  totalChargeTime: number;

  @Column("varchar", { name: "contact", comment: "联系人", length: 15 })
  contact: string;

  @Column("varchar", { name: "phone", comment: "联系电话", length: 20 })
  phone: string;

  @Column("smallint", {
    name: "province_id",
    unsigned: true,
    default: () => "'0'",
  })
  provinceId: number;

  @Column("smallint", { name: "city_id", unsigned: true, default: () => "'0'" })
  cityId: number;

  @Column("smallint", {
    name: "district_id",
    unsigned: true,
    default: () => "'0'",
  })
  districtId: number;

  @Column("varchar", { name: "address", length: 50 })
  address: string;

  @Column("varchar", { name: "remark", length: 100 })
  remark: string;

  @Column("tinyint", {
    name: "level",
    comment: "0:一级商户，1：二级商户",
    unsigned: true,
    default: () => "'0'",
  })
  level: number;

  @Column("int", { name: "parent_id", unsigned: true, default: () => "'0'" })
  parentId: number;

  @Column("tinyint", {
    name: "status",
    comment: "0:禁用，1：正常",
    unsigned: true,
    default: () => "'0'",
  })
  status: number;

  @Column("int", {
    name: "create_time",
    comment: "注册时间",
    unsigned: true,
    default: () => "'0'",
  })
  createTime: number;

  @Column("int", {
    name: "update_time",
    comment: "更新",
    unsigned: true,
    default: () => "'0'",
  })
  updateTime: number;

  @Column("int", {
    name: "last_login_time",
    comment: "最后登录时间",
    unsigned: true,
    default: () => "'0'",
  })
  lastLoginTime: number;

  @Column("json", { name: "roles", nullable: true })
  roles: object | null;
}
